<template>
  <div class="content">
    <!-- <div>
      <van-nav-bar title="订单详情" left-arrow @click-left="onClickLeft" />
    </div> -->
    <Loading :loading="loading">
      <NavBar></NavBar>
      <div>
        <div class="detail-header">
          <img src="./img/detail.png" alt="" />
          <div class="detail-title">{{ obj.productName }}</div>
          <div class="detail-baoxian">{{ obj.partnerName }}</div>
        </div>
        <div class="detail-card">
          <div class="detail-inline">
            <div class="detail-user">订单编号</div>
            <div class="detail-name">
              {{ obj.orderNo }}
              <img src="./img/fuzhi.png" alt="" />
            </div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">投保人</div>
            <div class="detail-name">
              {{ obj.appPolicyHolder.name }}
              <van-icon
                :name="show ? 'arrow-up' : 'arrow-down'"
                @click="hundleShow"
              />
            </div>
          </div>
          <div class="detail-inline" v-show="show">
            <div class="detail-user"></div>
            <div class="detail-name">备选投保人</div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">投保来源</div>
            <div class="detail-name">---</div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">投保时间</div>
            <div class="detail-name">
              {{ obj.inceptionDateStart }}
            </div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">首期保费</div>
            <div class="detail-name">
              {{ obj.appOrderPayPeriod.annualPrem }}
            </div>
          </div>
        </div>
        <div class="detail-baodan">
          <div class="baodan-title">保单</div>
          <!-- <div class="baodan-center">
          <div class="baodan-ok">
            <div class="baodan-name">{{ obj.productName }}</div>
            <img src="./img/fail.png" alt="" />
          </div>
          <div class="baodan-yes">
            <div class="detail-inline">
              <div class="detail-user">保单编号</div>
              <div class="detail-name">{{ obj.policyNo }}</div>
            </div>
            <div
              class="detail-inline"
              v-for="item in appPolicyInsuredList"
              :key="item.index"
            >
              <div class="detail-user">被保人</div>
              <div class="detail-name">{{ item.name }}</div>
            </div>
            <div class="detail-inline">
              <div class="detail-user">保障期间</div>
              <div class="detail-name">
                {{ obj.appPolicyRiskList.insurancePeriodName }}
              </div>
            </div>
            <div class="detail-inline">
              <div class="detail-user">每期保费</div>
              <div class="detail-name">{{ obj.appPolicyRiskList.premium }}</div>
            </div>
          </div>
        </div> -->
          <!--  -->
          <div class="cro c-2n5l32">
            <div class="cro_left_bottom"></div>
            <div class="cro_right_bottom"></div>
            <div class="c-2n5l32-title">
              {{ obj.productName }}
            </div>
            <img class="c-2n5l32-img" src="./img/fail.png" alt="" />
          </div>
          <div class="cro c-0y56ds">
            <div class="cro_left_top"></div>
            <div class="cro_right_top"></div>
            <div class="baodan-yes">
              <div class="detail-inline">
                <div class="detail-user">保单编号</div>
                <div class="detail-name">{{ obj.policyNo }}</div>
              </div>
              <div
                class="detail-inline"
                v-for="item in appPolicyInsuredList"
                :key="item.index"
              >
                <div class="detail-user">被保人</div>
                <div class="detail-name">{{ item.name }}</div>
              </div>
              <div class="detail-inline">
                <div class="detail-user">保障期间</div>
                <div class="detail-name">
                  {{ obj.appPolicyRiskList.insurancePeriodName }}
                </div>
              </div>
              <div class="detail-inline">
                <div class="detail-user">每期保费</div>
                <div class="detail-name">
                  {{ obj.appPolicyRiskList.premium }}
                </div>
              </div>
            </div>
          </div>
        </div>
        <div class="baodan-content">
          <div class="baodan-title">支付信息</div>
          <div class="detail-inline">
            <div class="detail-user">支付方式</div>
            <div class="detail-name">{{ obj.appOrderPayPeriod.payType }}</div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">续期缴费银行卡</div>
            <div class="detail-name">{{ obj.appOrderPayPeriod.cardNo }}</div>
          </div>
        </div>
        <div class="baodan-content">
          <div class="baodan-title">联系方式</div>
          <div class="detail-inline">
            <div class="detail-user">投保人手机</div>
            <div class="detail-name">{{ obj.appPolicyHolder.mobile }}</div>
          </div>
          <div class="detail-inline">
            <div class="detail-user">电子邮箱</div>
            <div class="detail-name">{{ obj.appPolicyHolder.email }}</div>
          </div>
        </div>
      </div>
      <div class="baodan-content">
        <div class="baodan-title">客户告知书</div>
        <div class="baodan-herf">{{ code }}</div>
        <van-button
          class="baodan-button"
          block
          :data-clipboard-text="code"
          @click="copyActiveCode('.baodan-button')"
        >
          复制链接
        </van-button>
      </div>
    </Loading>
  </div>
</template>
<script>
import Clipboard from 'clipboard'
import API from '@/services/h5/my'
import NavBar from '@/components/h5header'
import Loading from '@/components/data-loading'
export default {
  components: { NavBar, Loading },
  data() {
    return {
      show: false,
      icon: 'arrow-down',
      code: 'http',
      obj: {},
      appPolicyInsuredList: [],
      loading: false
    }
  },
  methods: {
    onClickLeft() {
      window.history.go(-1)
    },
    copyActiveCode(type) {
      const clipboard = new Clipboard(type)
      let that = this
      clipboard.on('success', function (e) {
        e.clearSelection()
        that.$toast('复制成功')
      })
    },
    getOrderDetail() {
      this.loading = true
      let params = {
        contractId: this.$route.params.id
      }
      API.orderDetail(params).then(res => {
        if (res.data && res.data.code === 1000) {
          this.obj = res.data.data
          this.appPolicyInsuredList = res.data.data.appPolicyInsuredList
        }
        this.loading = false
      })
    },
    hundleShow() {
      this.show = !this.show
    }
  },
  async mounted() {
    await this.getOrderDetail()
  }
}
</script>
<style scoped lang="less">
.content {
  background-color: #fafafa;
}
.detail-header {
  width: 375px;
  height: 80px;
  position: relative;
}
.detail-header img {
  width: 100%;
}
.detail-title {
  position: absolute;
  top: 50%;
  left: 15px;
  transform: translateY(-50%);
  font-size: 19.5px;
  color: #fff;
  font-weight: bold;
}
.detail-baoxian {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  right: 15px;
  font-size: 13px;
  color: #fff;
}
.detail-card {
  width: 345px;
  padding: 15px;
  background-color: #fff;
}
.detail-inline {
  padding: 5px 0;
  display: flex;
  justify-content: space-between;
}
.detail-user {
  font-size: 13px;
  color: #999;
}
.detail-name {
  font-size: 13px;
  color: #666;
}
.detail-baodan {
  width: 345px;
  padding: 15px;
  margin-top: 13px;
  background-color: #fff;
  box-shadow: rgba(0, 0, 0, 0.05) 0 1px 2px 0;
}
.baodan-title {
  font-size: 16px;
  color: #000;
  font-weight: bold;
  margin-bottom: 13px;
}
.baodan-center {
  width: 315px;
  padding: 0 15px 15px 15px;
  height: auto;
  display: inline-block !important;
  display: inline;
  background: radial-gradient(circle at left, transparent 10px, #333) left,
    radial-gradient(circle at right, transparent 10px, #333) right;
  background-repeat: no-repeat;
  background-size: 50% 100%;
  text-align: center;
  box-shadow: rgba(0, 0, 0, 0.07) 0 0 11.5px 0;
}
.baodan-ok {
  height: 60px;
  position: relative;
}
.baodan-content {
  width: 345px;
  padding: 15px;
  background-color: #fff;
  box-shadow: rgba(0, 0, 0, 0.05) 0 1px 2px 0;
  margin-top: 13px;
}
.baodan-name {
  position: absolute;
  top: 15px;
  font-size: 16px;
  font-weight: bold;
}
.detail-baodan img {
  position: absolute;
  top: 0;
  right: 0;
}
.baodan-herf {
  width: 345px;
  height: 22px;
  line-height: 22px;
  border: 1px solid #f68657;
  border-radius: 4px;
  font-size: 11px;
  color: #333;
  text-align: center;
}
.baodan-button {
  border-radius: 4.5px;
  background-color: #f68657;
  color: #fff;
  font-size: 13px;
  width: 90px;
  height: 25px;
  margin: 10px auto;
}
</style>
<style lang="less" scoped>
.cro_left_top,
.cro_right_top,
.cro_left_bottom,
.cro_right_bottom {
  position: absolute;
  width: 10px;
  height: 10px;
  // border: 1px solid rgba(0, 0, 0, 0.05);
  z-index: 1;
  background: #eee;
}
.cro_left_top {
  top: -1px;
  left: -1px;
  border-radius: 0 0 10px 0;
  // border-bottom: 1px solid #58c4e6;
  // border-right: 1px solid #58c4e6;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
}
.cro_right_top {
  top: -1px;
  right: -1px;
  border-radius: 0 0 0 10px;
  // border-bottom: 1px solid #58c4e6;
  // border-left: 1px solid #58c4e6;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
}
.cro_left_bottom {
  left: -1px;
  bottom: -1px;
  border-radius: 0 10px 0 0;
  // border-top: 1px solid #58c4e6;
  // border-right: 1px solid #58c4e6;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
}
.cro_right_bottom {
  right: -1px;
  bottom: -1px;
  border-radius: 10px 0 0 0;
  // border-top: 1px solid #58c4e6;
  // border-left: 1px solid #58c4e6;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
}
.c-2n5l32 {
  // border: 1px solid #58c4e6;
  position: relative;
  border-bottom: 1px dashed #ccc;
  margin-top: 10px;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
  &-title {
    font-size: 16px;
    font-weight: bold;
    color: #000;
    padding: 15px;
  }
  &-img {
    position: absolute;
    top: 0;
    right: 0;
    width: 102px;
  }
}
.c-0y56ds {
  // border: 1px solid #58c4e6;
  position: relative;
  border-top: none;
  box-shadow: rgba(0, 0, 0, 0.1) 0 0 20px 0;
  padding: 15px;
}
</style>
